package com.zjol

import java.io.File


/**
  * Created by Administrator on 2017/3/27.
  */
object funcation {


  /**
    * 无参数函数调用
    */
  def doWhile(): Unit = {
    var line = ""
    do {
      line = readLine()
      println("Read:" + line)
    } while (line != "")

  }


  /**
    * 计算最小公约数
    *
    * @param x
    * @param y
    * @return
    */
  def looper(x: Long, y: Long): Long = {
    var a = x;
    var b = y;
    while (a != 0) {
      val temp = a;
      a = b % a;
      b = temp
    }
    b
  }

  def forExample() = {
    for (i <- 1.to(10)) {
      println(i)
    }
    val files = new File(".").list();
    for (file <- files) {
      println(file)
    }

  }

  def catchEaxmple(): Unit ={
    val n=99
    try{
       n/0
    }catch {
      case  e:Exception =>println(e.getMessage)
    }finally {
      println("finally")
    }
  }


  def main(args: Array[String]): Unit = {

    println("Input String")
    // doWhile
    // println(looper(10, 6))
    //forExample()
    //catchEaxmple()

  }

}
